package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.entity.OrderItem;

import java.util.List;

/**
 * 订单项Mapper接口
 */
@Mapper
public interface OrderItemMapper extends BaseMapper<OrderItem> {

    /**
     * 根据订单ID查询订单项列表
     */
    @Select("SELECT * FROM t_order_item WHERE order_id = #{orderId}")
    List<OrderItem> selectByOrderId(@Param("orderId") Long orderId);

    /**
     * 根据用户ID查询订单项列表
     */
    @Select("SELECT * FROM t_order_item WHERE user_id = #{userId}")
    List<OrderItem> selectByUserId(@Param("userId") Long userId);

    /**
     * 根据产品ID查询订单项列表
     */
    @Select("SELECT * FROM t_order_item WHERE product_id = #{productId}")
    List<OrderItem> selectByProductId(@Param("productId") Long productId);
} 